home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Night Owl 6
/
Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso
/
010a
/
fdcrw100.zip
/
FDC-RW.ASM
next >
Wrap
Assembly Source File
|
1991-08-01
|
9KB
|
304 lines
name TSR
page 60,132
title FDC-RW.COM program -- Floppy Disk Controller Register Watch
;
; I needed to test a program ... this will be my first attempt at a TSR
;
; Jesse Monroy, 07-30-91
;
; to assemble: MASM fdc-rw.asm,,,,
; LINK fdc-rw;
; ignore no stack warning
CR equ 0dh
LF equ 0ah
monoseg equ 0b000h
colorseg equ 0b800h
scrnpos equ 008ch
main_stat_reg equ 03f4h
digital_out_reg equ 03f2h ; aka Drive control Register
monomode equ 07h
intr_to_trap equ 08h
bits_to_shift equ 08h
csegment segment word public 'CODE'
assume cs:csegment, ds:csegment, es:csegment, ss:csegment
org 100h
start_mycode:
jmp start_code
author db ' FDC Register Watch v1.0',cr,lf
db ' By Newind Inc.',cr,lf,lf,'$'
help_msg db ' Usage:regwatch [-options]',cr,lf
db ' options are :',cr,lf
db ' m - force monochrome video',cr,lf
db ' c - force color video',cr,lf
db ' r - reset the FDC and run the watch',cr,lf
db ' R - reset the FDC and exit',cr,lf
db ' n - use non-resident mode',cr,lf
cr_lf db cr,lf,'$'
LOAD_msg db ' Floppy Disk Controller - Register Watch'
db ' is loaded as a TSR!!',cr,lf,'$'
mono_msg db ' Using MonoChrome Video.',cr,lf,'$'
color_msg db ' Using Color Video.',cr,lf,'$'
nonres_msg db ' Running in Non memory resident mode.',cr,lf,'$'
reset_msg db ' FDC controller reset!',cr,lf,'$'
reset_x_msg db ' Exiting without installing FDC Register Watch.',cr,lf,'$'
one_char dw '1',70h ; '1'- one charecter in inverse attrib
zero_char dw '0',07h ; '0'- zero charecter in normal attrib
switches db 0
storage db 0
vid_offset dw scrnpos
vid_segment dw 0
vid_mode db 0
old_int_pointer equ this dword
old_offset dw ?
old_segment dw ?
TSR_code:
pushf
call cs:old_int_pointer ; call original ISR
cli ; disable (close) system interrupts
push es ; save registers
push si
push di
push ds
push ax
push cx
push dx
push cs ; point ds to cs
pop ds
mov dx, main_stat_reg
in al, dx ;get value of read only register
mov storage, al
sti ; set interrupt flag (start intr)
mov es,cs:vid_segment ; establish correct video base address
mov di, vid_offset ; establish correct video offset
cld ; increment form left to right
mov cx, bits_to_shift ; number of bits to print
next:
shl al, 01 ; shift bit to carry flag
jnc no_bit
mov si, offset one_char
jmp show
no_bit:
mov si, offset zero_char
show:
movsb ; move character into slot.
inc si ; explictly increment "si" -- bug fix
movsb ; move attrib into slot.
loop next
pop dx ;restore registers
pop cx
pop ax
pop ds
pop di
pop si
pop es
sti
iret ;issue EOI
TSR_code_end:
;===============
;
;
start_code:
PUSH CS ; point "ES" and "DS" to "CS"
PUSH CS
POP DS
POP ES
call cmdline
MOV AH, 0fh
INT 10h ;Get current display mode
mov vid_mode, al
test switches, 04h ; Reset the controller?
jz jmp2
mov dx, digital_out_reg
mov al, 00
out dx, al
reset:
mov dx, offset reset_msg ; "FDC controller reset
mov ah, 09h
int 21h
test switches, 10h ; exclusive Reset
jz jmp2 ; exit without TSR code
mov dx, offset reset_x_msg ; "FDC controller reset
mov ah, 09h
int 21h
jmp exxit ; may do an exclusive reset later
jmp2:
test switches, 01h ; check for forced monochrome mode
jnz mono
test switches, 02h ; check for forced color video
jnz color
CMP vid_mode, monomode ; check current video mode
jne color
mono:
MOV cs:vid_segment, monoseg ; load monochrome video segment
mov dx, offset mono_msg
mov ah, 09h
int 21h
jmp jmp1
color:
MOV cs:vid_segment, colorseg ; load color video segment
mov dx, offset color_msg
mov ah, 09h
int 21h
Jmp1:
MOV AH, 35h ;Get int vector
MOV AL, intr_to_trap
INT 21h
MOV WORD PTR old_offset, BX ; save offset of intr
MOV WORD PTR old_segment, ES ; save segment of int
MOV AH, 25h ; Set int vector
MOV AL, intr_to_trap ; to
MOV DX, offset TSR_code ; our intr code
INT 21h
test switches, 08h
jnz nonres
MOV DX, offset LOAD_msg
MOV AH, 09h
INT 21h ;"TSR Loaded!!"
MOV DX, offset TSR_code_end + 1
INT 27h ;Terminate/stay resident
nonres:
mov dx, offset nonres_msg
mov ah, 09h
int 21h
mov ah, 0ch ; clear keyboard buffer
mov al, 08h ; and wait for a key stroke
int 21h
cmp al, 0 ; look for extended keyboard
jne uninstall
mov ah, 0bh ; get any extra keystrokes
int 21h
uninstall:
push ds
MOV AH, 25h ; Set int vector
MOV AL, intr_to_trap ; to
MOV DX,old_offset ; old intr code.
mov ds,old_segment ; wait till the last second to change
; the "DS", otherwise other variables
INT 21h ; will be wrong
pop ds
jmp exxit
exxit:
mov ax, 4c00h
int 21h
;======================
;
; subroutine
cmdline proc near
jauthor:
mov dx, offset author
mov ah, 09h
int 21h
mov si, 0081h
cld
jtop:
lodsb
CMP AL, ' ' ; space -- filter 'em out
JE jtop
CMP AL, 0dh ; 0Dh = Carrige Return
JE go_jmp ; go to dummy jump spot
CMP AL, '-'
JE jcommand
CMP AL, '/'
JE jcommand
jmp help_jmp
jcommand:
; inc si
lodsb
CMP AL, 'R'
JE jreset2
CMP AL, 'r'
JE jreset
CMP AL, 'N'
JE jnonres
CMP AL, 'n'
JE jnonres
CMP AL, 'M'
JE jmono
CMP AL, 'm'
JE jmono
CMP AL, 'C'
JE jcolor
CMP AL, 'c'
JE jcolor
help_jmp:
JMP jhelp
go_jmp:
jmp jgo
jmono:
or switches,01h ; force monochrome mode
jmp jtop
jcolor:
or switches,02h ; force color mode
jmp jtop
jreset2:
or switches,10h ; exclusive reset (dont load the watch)
jreset:
or switches,04h ; reset controler on start
jmp jtop
jnonres:
or switches,08h ; reset controler on start
jmp jtop
jhelp:
mov dx, offset help_msg
mov ah, 09h
int 21h
jexiterror:
mov ax, 4c01h
int 21h
jgo:
ret
cmdline endp
csegment ends
end start_mycode